﻿@{
    ViewData["Title"] = "定时任务";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<div class="container-div white-bg">
    <div class="ibox-content">
        <form class="form form-horizontal" id="form" autocomplete="off">
            <input type="hidden" name="id" id="id" value="@(ViewBag.Id)">
            <div class="form-group">
                <label class="col-sm-3 control-label required">任务名称：</label>
                <div class="col-sm-6">
                    <input type="text" name="task_name" id="task_name" value="" class="form-control" data-rule="required">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label required">命名空间：</label>
                <div class="col-sm-6">
                    <input type="text" name="assembly_namespace" id="assembly_namespace" value="" class="form-control" data-rule="required">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label required">类名：</label>
                <div class="col-sm-6">
                    <input type="text" name="class_name" id="class_name" value="" class="form-control" data-rule="required;">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label required">Cron表达式：</label>
                <div class="col-sm-6">
                    <input type="text" name="cron_express" id="cron_express" class="form-control" data-rule="required;">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">任务说明：</label>
                <div class="col-sm-6">
                    <textarea name="remark" id="remark" cols="60" rows="4"></textarea>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="footerbar">
                <div class="col-sm-12 col-sm-offset-5">
                    <button class="btn btn-primary" type="submit"> <i class="fa fa-check"></i>保存</button>
                    <button class="btn btn-danger" type="button" onclick="cancel()"><i class="fa fa-reply-all"></i>关闭</button>
                </div>
            </div>
        </form>
    </div>
    </div>
    @section scripts{
        <script type="text/javascript">
            $(function () {
                $('#form').validator({
                    stopOnError: false,
                    timely: 2,
                    theme: "yellow_right",
                    valid: function (form) {
                        // 表单验证通过，提交表单
                        jutils.ajaxPost('/admin/hangfirejob/Save', $(form).serialize(),
                            function (res) {
                                cancel();
                            });
                    }
                });

                loadData();
            });


            function loadData() {
                var id = $("#id").val();
                if (jutils.emptyId(id)) {
                    return;
                }
                jutils.ajaxGet('/admin/hangfirejob/GetDataById', { id: id }, function (res) {
                    $('#form').initFormData(res.data.model);
                });
            }

            function cancel() {
                jutils.closeDialog();
            }
        </script>


    }







